def method(s):
    # 1 去掉前导0
    pz = 0
    while pz < len(s) and s[pz] == '0':
        pz += 1
    s = s[pz:]
    # print(f'del 0a: {s}')

    pz = 1
    if pz < len(s):
        while pz < len(s) and s[pz] == '0':
            pz += 1
        s = s[0] + s[pz:]
    # print(f'del 0: {s}')

    if s == '':
        return 0

    # 2 得分效果
    grades = [0]
    grade = 0
    for i in range(1, len(s)):
        if s[i] == '1':
            grade -= 1
        elif s[i] == '0':
            grade += 1
        grades.append(grade)
    # print(f'grades: {grades}')

    max_index = grades.index(max(grades))

    result_s = s[0] + s[max_index+1:]
    # print(f'result_s: {result_s}')

    # 3 计算最终得分
    result = 0
    for c in result_s:
        if c == '1':
            result += 1
        elif c == '0':
            result -= 1 
    return result

if __name__ == '__main__':
    s = input()
    result = method(s)
    print(result)
